package com.ruoyi.work.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.work.domain.TbEquTrain;
import com.ruoyi.work.service.ITbEquTrainService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 救援车辆台账Controller
 *
 * @author szm
 * @date 2025-10-21
 */
@Api(tags = "救援车辆台账")
@RestController
@RequestMapping("/work/TbEquTrain")
public class TbEquTrainController extends BaseController {
    @Autowired
    private ITbEquTrainService tbEquTrainService;

    /**
     * 查询救援车辆台账列表
     */
    @ApiOperation("查询救援车辆台账列表")
    @GetMapping("/list")
    public TableDataInfo list(TbEquTrain entity, HttpServletRequest req) {
        startPage();
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.setEntity(entity);
        List<TbEquTrain> list = tbEquTrainService.list(wrapper);
        return getDataTable(list);
    }

    /**
     * 导出救援车辆台账列表
     */
    @ApiOperation("导出救援车辆台账列表")
    @Log(title = "救援车辆台账", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(HttpServletResponse response, TbEquTrain entity) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.setEntity(entity);
        List<TbEquTrain> list = tbEquTrainService.list(wrapper);
        ExcelUtil<TbEquTrain> util = new ExcelUtil<TbEquTrain>(TbEquTrain. class);
        util.exportExcel(response, list, "救援车辆台账数据");
    }

    /**
     * 获取救援车辆台账详细信息
     */
    @ApiOperation("获取救援车辆台账详细信息")
    @GetMapping(value = "/getById")
    public AjaxResult getById(@RequestParam("id") String id) {
        return success(tbEquTrainService.getById(id));
    }

    /**
     * 新增救援车辆台账
     */
    @ApiOperation("新增/修改救援车辆台账")
    @Log(title = "新增/修改救援车辆台账", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody TbEquTrain entity) {
        return toAjax(tbEquTrainService.saveOrUpdate(entity));
    }

    /**
     * 删除救援车辆台账
     */
    @ApiOperation("删除救援车辆台账")
    @Log(title = "救援车辆台账", businessType = BusinessType.DELETE)
    @PostMapping("/delIds")
    public AjaxResult remove(@RequestParam("ids") String ids) {
        return toAjax(tbEquTrainService.removeById(ids));
    }


}
